<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1,minimum-scale=1,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/font/font-awesome-4.7.0/css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="/public/static/wx/css/work-order-list.css" />
    <script src="/public/static/wx/js/flex.js" type="text/javascript" charset="utf-8"></script>
    <title>工单列表</title>
</head>

<body>
<div class="index">
    <div class="top-img"></div>
    <div class="order-list" id="dataList">
        <!--<div class="order-box clearfix">
            <div class="title-box clearfix">
                <p class="title">风电机器维修</p>
                <span></span>
                <p class="time">09:16:31</p>

            </div>
            <div class="content-box clearfix">
                <div class="fix"></div>
                <div class="word-box">
                    <p class="kind-title">故障类型：</p>
                    <p class="kind-des">风机的齿轮不动，请尽快解决一下</p>
                </div>
                <div class="btn-list">
                    <div class="check-detail">
                        查看详情
                    </div>
                </div>
            </div>
        </div>-->


    </div>

</div>
<script src="/public/static/wx/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">

    var url = '{:url("queryWork")}';

    var A_obj = {
        page:1,
        limit:10,
        per:2,
    };

    $.post(url,A_obj,call);


    function call(data) {
        A_obj.per = Math.ceil(data.count/A_obj.limit);

        var dom = $('<div class="order-box clearfix" onclick="info(this)">\n' +
            '            <div class="title-box clearfix">\n' +
            '                <p class="title"></p>\n' +
            '                <span></span>\n' +
            '                <p class="time c_time"></p>\n' +
            '            </div>\n' +
            '            <div class="content-box clearfix">\n' +
            '                <div class="fix"></div>\n' +
            '                <div class="word-box">\n' +
            '                    <p class="kind-title">故障类型：</p>\n' +
            '                    <p class="kind-des fault_name"></p>\n' +
            '                </div>\n' +
            '                <div class="btn-list">\n' +
            '                    <div class="check-detail">\n' +
            '                        查看详情\n' +
            '                    </div>\n' +
            '                </div>\n' +
            '            </div>\n' +
            '        </div>');
        $('#dataList').empty();
        $.each(data.data,function (k,v) {
            var ts = dom.clone();
            ts.find('.title').text(v.title);
            ts.find('.number').text(v.number);
            ts.find('.fault_name').text(v.fault_name);
            ts.find('.c_time').text(v.c_time);
            ts.find('.state_name').text(v.state_name);

            ts.attr('did',v.id);

            $('#dataList').append(ts);
        });

    }

    function info(_t){
        var id = $(_t).attr('did');
        location.href = '{:url("getWorkUI")}?id='+id;
    }


    function sub(){
        var key = $('#key').val();

        A_obj.key = key;

        $.post(url,A_obj,call);
    }

    //滚动加载
    $(window).scroll(function () {

        if(A_obj.page < A_obj.per){

            var scrollTop = $(this).scrollTop();
            var scrollHeight = $(document).height();
            var windowHeight = $(this).height();

            if (scrollTop + windowHeight == scrollHeight ) {

                A_obj.page++;
                $.post(url,A_obj,call);

            }
        }
    });

</script>
</body>

</html>